import axios from "axios";
import 'nprogress/nprogress.css';

// 创建axios实例
const request = axios.create({
  baseURL: 'http://127.0.0.1:3007',
  timeout: 5000,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  }
})

// 请求拦截器
request.interceptors.request.use(config => {
  // NProgress.start();
  return config
}, error => {
  // NProgress.done()
  return Promise.reject(error)
})

// 响应拦截器
request.interceptors.response.use(response => {
  // NProgress.start();
  return response.data
}, error => {
  // NProgress.done()
  return Promise.reject(error)
})

export default request
